/*
 * WallList.java
 *
 * Created on October 23, 2007, 10:52 AM
 */

package jia.editor.lists;

import java.awt.Rectangle;
import javax.swing.JInternalFrame;
import javax.swing.JViewport;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import jia.editor.EditorMain;
import jia.editor.widgets.WallSheetPreviewPanel;
import jia.tools.PanelSwapper;

/**
 *
 * @author  estell
 */
public class pnl_WallList extends javax.swing.JPanel {
    
    /** Creates new form WallList */
    public pnl_WallList() {
        initComponents();
tbl_WallList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
  public void valueChanged(ListSelectionEvent ev) {
        String selectedFileName = tbl_WallList.getValueAt(tbl_WallList.getSelectedRow(), 1).toString();
        WallSheetPreviewPanel prvw = new WallSheetPreviewPanel(selectedFileName);
        prvw.setVisible(true);
        //scrl_WallListPreview.add(prvw);
        scrl_WallListPreview.getViewport().setView(prvw);
        prvw.scrollRectToVisible(new Rectangle(576, 368));
        
        scrl_WallListPreview.revalidate();    
  }
});        
        
        
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        pop_WallListContext = new javax.swing.JPopupMenu();
        mnu_WallListAdd = new javax.swing.JMenuItem();
        mnu_WallListEdit = new javax.swing.JMenuItem();
        mnu_WallListDelete = new javax.swing.JMenuItem();
        scrl_WallListTable = new javax.swing.JScrollPane();
        tbl_WallList = new javax.swing.JTable();
        btn_WallListCancel = new javax.swing.JButton();
        btn_WallListHelp = new javax.swing.JButton();
        scrl_WallListPreview = new javax.swing.JScrollPane();

        mnu_WallListAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jia_ui/images/add.png")));
        mnu_WallListAdd.setText(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Add_lbl"));
        mnu_WallListAdd.setToolTipText(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Add"));
        mnu_WallListAdd.setActionCommand(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Add_lbl"));
        mnu_WallListAdd.setLabel(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Add_lbl"));
        mnu_WallListAdd.setName(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Add_lbl"));
        pop_WallListContext.add(mnu_WallListAdd);
        mnu_WallListAdd.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Add_lbl"));
        mnu_WallListAdd.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Add"));

        mnu_WallListEdit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jia_ui/images/pencil.png")));
        mnu_WallListEdit.setText(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Edit_lbl"));
        mnu_WallListEdit.setToolTipText(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Edit"));
        mnu_WallListEdit.setActionCommand(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Edit_lbl"));
        mnu_WallListEdit.setLabel(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Edit_lbl"));
        mnu_WallListEdit.setName(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Edit_lbl"));
        pop_WallListContext.add(mnu_WallListEdit);
        mnu_WallListEdit.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Edit_lbl"));
        mnu_WallListEdit.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Edit"));

        mnu_WallListDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jia_ui/images/delete.png")));
        mnu_WallListDelete.setText(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Delete_lbl"));
        mnu_WallListDelete.setToolTipText(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Delete"));
        mnu_WallListDelete.setActionCommand(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Delete_lbl"));
        mnu_WallListDelete.setLabel(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Delete_lbl"));
        mnu_WallListDelete.setName(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Delete_lbl"));
        mnu_WallListDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnu_WallListDeleteActionPerformed(evt);
            }
        });

        pop_WallListContext.add(mnu_WallListDelete);
        mnu_WallListDelete.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Delete_lbl"));
        mnu_WallListDelete.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Delete"));

        setPreferredSize(new java.awt.Dimension(800, 580));
        tbl_WallList.setComponentPopupMenu(pop_WallListContext);
        tbl_WallList.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Cyric", "cyric-wall_01a.png"},
                {"Stone Door", "stoneDoor01.png"},
                {"Green Stone Wall", "eob_stonewall03a.bmp"},
                {"Stairs Up", "Stairs_up_01.bmp"},
                {"Brown Stone Wall", "wa_StoneWall.png"},
                {"Stone Wall", "stoneWall01.png"}
            },
            new String [] {
                "Name", "File Name"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        tbl_WallList.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbl_WallListMouseClicked(evt);
            }
        });

        scrl_WallListTable.setViewportView(tbl_WallList);

        btn_WallListCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jia_ui/images/door_out.png")));
        btn_WallListCancel.setText(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Cancel_lbl"));
        btn_WallListCancel.setToolTipText(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Cancel"));
        btn_WallListCancel.setActionCommand(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Cancel_lbl"));
        btn_WallListCancel.setLabel(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Cancel_lbl"));
        btn_WallListCancel.setName(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Cancel_lbl"));
        btn_WallListCancel.setPreferredSize(new java.awt.Dimension(132, 30));
        btn_WallListCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_WallListCancelActionPerformed(evt);
            }
        });

        btn_WallListCancel.getAccessibleContext().setAccessibleName(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Cancel_lbl"));
        btn_WallListCancel.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Cancel"));

        btn_WallListHelp.setIcon(new javax.swing.ImageIcon(getClass().getResource("/jia_ui/images/help.png")));
        btn_WallListHelp.setText(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Help_lbl"));
        btn_WallListHelp.setToolTipText(java.util.ResourceBundle.getBundle("jia_ui/images/formUI").getString("btn_Help"));
        btn_WallListHelp.setPreferredSize(new java.awt.Dimension(132, 30));

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(btn_WallListHelp, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 512, Short.MAX_VALUE)
                        .add(btn_WallListCancel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                        .add(scrl_WallListTable, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(scrl_WallListPreview, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 576, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(scrl_WallListTable, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE)
                    .add(scrl_WallListPreview, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 520, Short.MAX_VALUE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(btn_WallListCancel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(btn_WallListHelp, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void tbl_WallListMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbl_WallListMouseClicked
        //System.out.println("A Row was clicked:" + tbl_WallList.getSelectedRow());
        String selectedFileName = tbl_WallList.getValueAt(tbl_WallList.getSelectedRow(), 1).toString();
        WallSheetPreviewPanel prvw = new WallSheetPreviewPanel(selectedFileName);
        prvw.setVisible(true);
        //scrl_WallListPreview.add(prvw);
        scrl_WallListPreview.getViewport().setView(prvw);
        prvw.scrollRectToVisible(new Rectangle(576, 368));
        
        scrl_WallListPreview.revalidate();
        
    }//GEN-LAST:event_tbl_WallListMouseClicked

    private void btn_WallListCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_WallListCancelActionPerformed
        PanelSwapper.swap(EditorMain.p_defaultAdminPanel, this); 
    }//GEN-LAST:event_btn_WallListCancelActionPerformed

    private void mnu_WallListDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnu_WallListDeleteActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_mnu_WallListDeleteActionPerformed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btn_WallListCancel;
    private javax.swing.JButton btn_WallListHelp;
    private javax.swing.JMenuItem mnu_WallListAdd;
    private javax.swing.JMenuItem mnu_WallListDelete;
    private javax.swing.JMenuItem mnu_WallListEdit;
    private javax.swing.JPopupMenu pop_WallListContext;
    private javax.swing.JScrollPane scrl_WallListPreview;
    private javax.swing.JScrollPane scrl_WallListTable;
    private javax.swing.JTable tbl_WallList;
    // End of variables declaration//GEN-END:variables
    
}
